<div class="content-wrapper">
    <section class="content-header">
        <h1>
            <if condition="$flag eq 2">
                已申请发票
                <elseif condition="$flag eq 1" />
                待申请发票
                <else />
                发票列表
            </if>
        </h1>
        <ol class="breadcrumb">
            <li><a href="/"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li class="active">订单管理</li>
            <li class="active">
                <if condition="$flag eq 2">
                    已申请发票
                    <elseif condition="$flag eq 1" />
                    待申请发票
                    <else />
                    发票列表
                </if>
            </li>
        </ol>
    </section>
    <section class="content">
        <div class="box">
            <div class="box-header with-border">
                <form class="form-inline" action="/customer/salesmanBillList" method="get">
                    <div class="form-group">
                        <input type="hidden" class="form-control" id="flag" name="flag" value="{$flag}">
                        <label class="label-control" for="type">发票类型 </label>
                        <select id="type" name="type" class="form-control">
                            <option value="0">请选择</option>
                            <foreach name="bill_typeList" item="b_val" key="b_key">
                                <option value="{$b_key}" <if condition="$b_key eq $type">selected</if>>{$b_val}</option>
                            </foreach>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="company_name">公司名 </label>
                        <input type="text" class="form-control" id="company_name" name="company_name" placeholder="客户名称" value="{$company_name}">
                    </div>
                    <button type="submit" class="btn btn-info" id="save-btn">查询</button>
                </form>
            </div>
            <div class="box-body table-responsive">
                <table class="table table-bordered">
                    <tbody>
                    <tr>
                        <th style="width: 80px">ID</th>
                        <th>订单ID</th>
                        <th>发票类型</th>
                        <th>公司名称</th>
                        <th>推广产品/游戏</th>
                        <th>产品类型</th>
                        <th>开票金额</th>
                        <th>状态</th>
                        <th>申请时间</th>
                        <th>部门</th>
                        <th>部门人员</th>
                        <th style="width: 100px">操作</th>
                    </tr>
                    <if condition="count($billList) eq 0"><tr><td class="text-center" colspan="10">暂无数据...</td></tr></if>
                    <foreach name="billList" item="bill">
                        <tr>
                            <td>{$bill.id}</td>
                            <td>{$bill.order_code}</td>
                            <td>{$bill['type_desc']}</td>
                            <td>{$bill.company_title}</td>
                            <td>{$bill.item_name}</td>
                            <td>{$bill.item_type}</td>
                            <td>{$bill.amount}</td>
                            <td><p>{$bill.status_desc}</p>
                                <if condition="$bill.status eq 1 ">
                                    <if condition="$bill.dp_manager_review eq 1 ">
                                        <span class="label label-success">已通过</span>
                                        <else />
                                        <span class="label label-danger">已拒绝</span>
                                    </if>
                                    <elseif condition="$bill.status eq 5 " />
                                    <if condition="$bill.director_review eq 1 ">
                                        <span class="label label-success">已通过</span>
                                        <else />
                                        <span class="label label-danger">已拒绝</span>
                                    </if>
                                    <elseif condition="$bill.status eq 10 " />
                                    <if condition="$bill.g_manager_review eq 1 ">
                                        <span class="label label-success">已通过</span>
                                        <else />
                                        <span class="label label-danger">已拒绝</span>
                                    </if>
                                </if>
                            </td>
                            <td>{$bill.create_time}</td>
                            <td>{$bill.department_name}</td>
                            <td>{$bill.admin_name}</td>
                            <td style="width: 100px">
                                <button class="btn btn-success btn-xs " type="button" data-id="{$bill.id}" onclick="window.location.href='/admin/customer/orderBillDetail?id={$bill.id}'">详情</button>&nbsp;
                                <button class="btn bg-maroon btn-xs btn-delete" type="button" data-id ="{$bill.id}">删除</button>&nbsp;
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
            </div>
            <div class="box-footer clearfix">{$page_html}</div>
        </div>
    </section>
</div>
<script src="__PUBLIC__/AdminLTE/plugins/layer/layer.js"></script>
<script type="application/javascript">
    $(function () {
        //删除
        $(".btn-delete").click(function () {
            var bill_id = $(this).attr('data-id');
            layer.confirm('确认删除该发票吗？',function () {
                $.post('/admin/customer/ajaxDeleteOrderBill',{
                    bill_id: bill_id
                },function (data) {
                    if(data.Code == 999) {
                        layer.alert('操作成功', {
                            skin: 'layui-layer-molv' //样式类名
                            ,closeBtn: 0
                        }, function(){
                            window.location.href = '/admin/customer/salesmanBillList';
                        });
                    } else {
                        layer.alert(data.Msg, {
                            skin: 'layui-layer-molv' //样式类名
                            ,closeBtn: 0
                        });
                    }
                },"JSON");
            });
        });
    });
</script>